#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import os.path
import string
rootdir = "."                                   # 指明被遍历的文件夹

for parent,dirnames,filenames in os.walk(rootdir):    #三个参数：分别返回1.父目录 2.所有文件夹名字（不含路径） 3.所有文件名字
    dest = file("./dest.txt","a")
    for filename in filenames:                        #输出文件信息
        if string.find(filename,".java")<>-1 or string.find(filename,"persistence")<>-1:
            print "filename is:" + os.path.join(parent,filename)
            f=file(os.path.join(parent,filename),"r+")
            dest.writelines(f.read())
            dest.flush()
            f.close()
    dest.close()
